﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ProductInputModel>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Chi tiết tin rao vặt
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>

    <script type="text/javascript">
        $(function() {
            $("#projectTabs").tabs();
        });
    </script>

    <div class="projectDetails">
        <div id="projectTabs">
            <ul>
                <li><a href="#projectTabs-1">Thông tin chi tiết</a></li>
                <li><a href="#projectTabs-2" id="googleTabs">Google Map</a></li>
                <li><a href="#projectTabs-3">Ảnh tin rao</a></li>
                <li><a href="#projectTabs-4">Thuộc tính mở rộng</a></li>
                <li><a href="#projectTabs-5">Thông tin khách hàng</a></li>
            </ul>
            <div id="projectTabs-1">
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                Phân mục
                            </td>
                            <td>
                                <%=Model.Product.ProductCategory.Name %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tỉnh/Thành phố
                            </td>
                            <td>
                                <%=Model.Product.City.Name %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Quận/Huyện
                            </td>
                            <td>
                                <%=Model.Product.District.Name %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Loại tin
                            </td>
                            <td>
                                <%=Model.Product.ProductType.Name %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tiêu đề
                            </td>
                            <td>
                                <%= Model.Product.Title %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Địa chỉ
                            </td>
                            <td>
                                <%= Model.Product.Adress %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Nội dung
                            </td>
                            <td>
                                <%=Model.Product.Summary %>
                            </td>
                        </tr>
<%--                        <tr>
                            <td class="key">
                                Mô tả
                            </td>
                            <td>
                                <%=Model.Product.ProductContent %>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="key">
                                Hướng nhà
                            </td>
                            <td>
                                <%=Model.CurrentDirection %>      
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Số tầng
                            </td>
                            <td>
                                <%=Model.Product.Floors %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Số phòng
                            </td>
                            <td>
                                <%=Model.Product.Rooms %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Giá
                            </td>
                            <td>
                                <% string totCos = !string.IsNullOrEmpty(Model.Product.Cost.ToString()) ? Model.Product.Cost.ToString() : string.Empty;
                                   
                                   string str = string.Empty;
                                   if (!string.IsNullOrEmpty(Model.Product.Cost.ToString()))
                                   {
                                       int count = 0;
                                       for (int i = totCos.Length - 1; i >= 0; i--)
                                       {
                                           count++;
                                           str = totCos[i] + str;
                                           if (count % 3 == 0)
                                               str = "." + str;
                                       }
                                   }
                                %>
                                <%= Model.Product.TotalCost.HasValue ? str + " ( " +  Model.Product.CurrencyName+ Model.Product.UnitCost +" ) " : string.Empty%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Thứ tự ưu tiên
                            </td>
                            <td>
                                <%=Model.Product.Priority %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Ngày hết hạn
                            </td>
                            <td>
                                <%=string.Format("{0:dd/MM/yyyy}",Model.Product.ExpireDate) %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Trạng thái hiển thị
                            </td>
                            <td>
                                <%= Html.RadioButton("Product.PubYN", true, Model.Product.PubYN)%>
                                Đăng tin
                                <%= Html.RadioButton("Product.PubYN", false, !Model.Product.PubYN)%>
                                Không đăng
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tin HOT
                            </td>
                            <td>
                                <%= Html.RadioButton("Product.HotYN", true, Model.Product.HotYN)%>
                                Tin HOT
                                <%= Html.RadioButton("Product.HotYN", false, !Model.Product.HotYN)%>
                                Tin không HOT
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tin VIP
                            </td>
                            <td>
                                <%= Html.RadioButton("Product.VIPYN", true, Model.Product.VipYN)%>
                                Tin VIP
                                <%= Html.RadioButton("Product.VIPYN", false, !Model.Product.VipYN)%>
                                Tin không VIP
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metadescription
                            </td>
                            <td>
                                <%=Model.Product.MetaDescription %>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metakeyword
                            </td>
                            <td>
                                <%=Model.Product.MetaKeyword%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metatag
                            </td>
                            <td>
                                <%=Model.Product.MetaTag%>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div id="projectTabs-2">
                <div id="maps" onunload="GUnload()">
                    <style type="text/css">
                        .map
                        {
                            width: 804px;
                            padding: 10px;
                            overflow: hidden;
                            margin-left: 60px;
                        }
                        .map img
                        {
                        }
                        .info
                        {
                            width: 804px;
                            overflow: hidden;
                        }
                        .infoL
                        {
                            float: left;
                            margin: 5px 0 0 0;
                            padding-top: 0px;
                        }
                        .infoL p
                        {
                            font: 12px Arial;
                            color: #0096db;
                            font-weight: bold;
                            margin-top: 0px;
                        }
                        .infoL .note
                        {
                            width: 483px;
                            padding: 7px;
                            height: 50px;
                            background-color: #e8e8e8;
                            overflow: hidden;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            line-height: 16px;
                        }
                        .infoR
                        {
                            float: right;
                            margin: 20px 2px 0 0;
                        }
                        .button1
                        {
                            width: 63px;
                            height: 24px;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            cursor: pointer;
                        }
                        .button2
                        {
                            width: 116px;
                            height: 24px;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            cursor: pointer;
                        }
                    </style>

                    <script type="text/javascript">

                        $(document).ready(function() {
                            $("#googleTabs").click(function() {
                                initialize();
                                showAddress();
                            });
                        });
                    
                    </script>

                    <script src="http://maps.google.com/maps?file=api&amp;v=3&amp;sensor=true&amp;key=<%= Model.GoogleAPI %>"
                        type="text/javascript"></script>

                    <script type="text/javascript">
                        var map = null;
                        var geocoder = null;

                        function initialize() {
                            if (GBrowserIsCompatible()) {
                                map = new GMap2(document.getElementById("map_canvas"));
                                map.setCenter(new GLatLng(21.033, 105.850), 15);
                                map.setUIToDefault();
                                geocoder = new GClientGeocoder();
                                var marker = new GMarker(new GLatLng(21.033, 105.850), { draggable: false });

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {

                                    //marker.openInfoWindowHtml("aaaaa"+ marker.getLatLng());
                                    document.getElementById("Product_Latitube").value = marker.getLatLng().lat();
                                    document.getElementById("Product_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                        }

                        function showAddress() {
                            var lat, lng;
                            lat = document.getElementById("Product_Latitube").value;
                            lng = document.getElementById("Product_Longitude").value;
                            if (lat == '' && lng == '' || lat == 0 && lng == 0) {
                                map.clearOverlays();
                                map.setCenter(new GLatLng(21.033, 105.850), 15);
                                var marker = new GMarker(new GLatLng(21.033, 105.850), { draggable: false });

                                document.getElementById("Product_Latitube").value = marker.getLatLng().lat();
                                document.getElementById("Product_Longitude").value = marker.getLatLng().lng();

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {
                                    document.getElementById("Product_Latitube").value = marker.getLatLng().lat();
                                    document.getElementById("Product_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                            else {
                                map.clearOverlays();
                                map.setCenter(new GLatLng(lat, lng), 15);
                                var marker = new GMarker(new GLatLng(lat, lng), { draggable: false });

                                document.getElementById("Product_Latitube").value = marker.getLatLng().lat();
                                document.getElementById("Product_Longitude").value = marker.getLatLng().lng();

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {

                                    //marker.openInfoWindowHtml("aaaaa"+ marker.getLatLng());
                                    document.getElementById("Product_Latitube").value = marker.getLatLng().lat();
                                    document.getElementById("Product_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                        }
                    </script>

                    <div class="map">
                        <div id="map_canvas" style="width: 100%; height: 400px; padding-bottom: 10px; position: relative;">
                        </div>
                        <%= Html.HiddenFor(m=>m.Product.Latitube) %>
                        <%= Html.HiddenFor(m=>m.Product.Longitude) %>
                        <div class="info">
                            <%--<div class="infoL">
                    <p style="display: none" id="idHoanTat">
                        <img src="../images/ico_map_check.gif" width="22" height="22" alt="" />&nbsp;Vị
                        trí tài sản đã được cập nhật !</p>
                    <div class="note">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="9%">
                                    <img src="../images/ico_map_help.gif" width="36" height="44" alt="" />
                                </td>
                                <td width="91%">
                                    Sử dụng con trỏ chuột di chuyển icon (<img src="/Images/map_ico.gif" width="12" height="16"
                                        alt="" />
                                    ) đến vị trí của tài sản trên bản đồ. Nhấn nút “Cập nhật vị trí” để cập nhật vị
                                    trí cho tài sản.
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>--%>
                            <div class="infoR">
                                <%--<input type="button" name="cmdFinish" class="button2" id="cmdFinish" value="Cập nhật vị trí"
                                    onclick="LocationFinished();" />&nbsp;
                                <input type="button" name="cmdClose" class="button1" id="cmdClose" value="Đóng lại"
                                    onclick="LocationFinishedClose();" />--%>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="projectTabs-3">
                <ul>
                    <% if (Model.ListFile != null && Model.ListFile.Count() > 0)
                       {
                           foreach (string item in Model.ListFile)
                           {
                               if (!string.IsNullOrEmpty(item))
                               {
                    %>
                    <li style="display: inline;">
                            <img width="110" height="75" style="border: 1px solid #CCCCCC;" class="bor_img" alt=""
                                src="<%= string.Format("{0}{1}",Model.ImageRootUrl,item )%>" />  
                    </li>
                    <%}
                           }
                       }%>
                </ul>
              
            </div>
            <div id="projectTabs-4">
                <table class="admintable">
                <tbody>
                     <% foreach (var itemAttribute in Model.ListProductAtribute)
                        {
                            var testChecked = "";
                            if (Model.ListProductAttributeID.Contains(itemAttribute.ID)) testChecked = "checked";   
                             %>
                             <tr>
                                <td class="key"><%=itemAttribute.Name %></td>
                                <td>
                                    <input type="checkbox" id="" name="" <%=testChecked %> />
                                </td>
                             </tr>
                      <%} %>      
                     </tbody>
                </table>
            </div>
            <div id ="projectTabs-5">
			<table class="admintable" width="100%">
				<tbody>
					<tr>
						<td class="key">
							Họ tên:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactName)%>
						</td>
					</tr>				
					<tr>
						<td class="key">
							Địa chỉ:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactAddress)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							Công ty:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.Company)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							Email:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactEmail)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							Mobile:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactMobile)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							Yahoo:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactYahoo)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							MSN:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactMSN)%>
						</td>
					</tr>
					<tr>
						<td class="key">
							Skype:
						</td>
						<td style ="padding:5px;">
							<%=Html.Encode(Model.Product.ContactSkype)%>
						</td>
					</tr>
				</tbody>
			</table>
        </div>
        </div>
    </div>
    <%} %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
        <%= Html.Toolbar("Sửa",string.Format("/Product/Edit/{0}",Model.Product.ID), "edit")%>
    </td>
    <td>
        <%= Html.Toolbar("Xoá", "/Product/Delete/" + Model.Product.ID, "delete")%>
    </td>
    <td>
        <%= Html.Toolbar("Quay về", "/Product", "back")%>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Chi tiết tin rao vặt
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
